﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EventsExample
{
    class Program
    {
        static void Main(string[] args)
        {
            PublishingHouse ranok = new PublishingHouse();
            PublishingHouse mif = new PublishingHouse();

            Subscriber s1 = new Subscriber("Maksim");
            Subscriber s2 = new Subscriber("Vasya");
            Subscriber s3 = new Subscriber("Nikolay");

            ranok.NewMagazine += s1.BuyMagazine;
            ranok.NewMagazine += s2.BuyMagazine;
            mif.NewMagazine += s3.BuyMagazine;
            mif.NewMagazine += s1.BuyMagazine;

            ranok.PublishMagazine("Murzilka", 1, "Murzilka the best", 5);

            Console.WriteLine();

            mif.PublishMagazine("Как написать змейку", 1, "Быстро и решительно!", 1);


        }
    }

    class Subscriber
    {
        private readonly string _name;

        public Subscriber(string name)
        {
            _name = name;
        }

        public void BuyMagazine(object sender, MagazineEventArgs e)
        {
            Console.WriteLine("{0}, run to the shop and buy {1} magazine volume {2}", _name, e.Name, e.Volume);
        }
    }
}
